package thread.proxy;

public class TestLamda {
    static class Love implements Ilove {
        @Override
        public void love(String name) {
            System.out.println("1.I love "+name+"?");
        }
    }

    public static void main(String[] args) {
        Love love = new Love();
        love.love("loli");

        Ilove like = new Ilove() {
            @Override
            public void love(String name) {
                System.out.println("3.I love "+name+"?");
            }
        };
        like.love("loli");

        //Lamda表达式
        //1.Lamda表示简化
        like = (String name)->{
            System.out.println("4.I love "+name+"?");
        };
        like.love("loli");
        //2.参数类型简化
        like = (name) -> {
            System.out.println("5.I love "+name+"?");
        };
        like.love("loli");
        //3.括号简化
        like = name -> {
            System.out.println("6.I love "+name+"?");
        };
        like.love("loli");
        //4.花括号简化
        like = name -> System.out.println("7.I love "+name+"?");
        //总结：Lamda表达式，仅当函数式接口可以实现。
        //Lamda括号简化取决于参数个数，花括号简化取决于函数语句数量。
    }
}

interface Ilove {
    public void love(String name);
}

class Love implements Ilove {
    @Override
    public void love(String name) {
        System.out.println("2.I love "+name+"?");
    }
}